﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Common 的摘要说明
/// </summary>
public class Common
{
	public Common()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    public bool IsDebug = bool.Parse(ConfigurationManager.AppSettings["IsDebug"].ToString());

    public string EntName = ConfigurationManager.AppSettings["EntName"].ToString();

    MsSqlHelper mssql = new MsSqlHelper();
    public string djbh { get; set; }
    //public string ndjbh { get; set; }

    public void Init()
    {
        string sql = "select max(imageid) as id from [ImageDoc](nolock) where left(imageid,3)='TUP'";
        SqlDataReader dr1 = mssql.ExecuteReader(sql);
        if (dr1.Read())
        {
            djbh = dr1["id"].ToString();
        }
    }

    #region 初始化网页头
    public string InitDefault()
    {
        LicenseState();
        string retsult = "";
        try
        {
            retsult += "<!DOCTYPE html>\r\n";
            retsult += "<html>\r\n";
            retsult += "<head>\r\n";
            retsult += "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n";
            retsult += "    <title>电子文档管理平台 - Powered by " + EntName + "</title>\r\n";
            retsult += "    <link href=\"/Public/Home/css/Member.css\" rel=\"stylesheet\" type=\"text/css\">\r\n";
            retsult += "<style type=\"text/css\">\r\n";
            retsult += "<!--\r\n";
            retsult += "    .QiyeC a{border:1px solid #d2ccc4;color:#666;padding: 3px 10px;display:inline-block;margin:5px 0;}\r\n";
            retsult += "    #delImage{display: block; position: absolute;bottom:5px;right:5px;background:#e95515;border:none;color:#FFF;overflow:visible;padding:5px 10px;cursor:pointer;}\r\n";
            retsult += "    .alert-warning{\r\n";
            retsult += "	    position:relative;\r\n";
            retsult += "	    margin:0 30px 15px;\r\n";
            retsult += "	    padding:25px;\r\n";
            retsult += "	    color:#a94442;\r\n";
            retsult += "	    background-color:#f2dede;\r\n";
            retsult += "	    border:1px solid #ebccd1;\r\n";
            retsult += "	    border-radius:4px;\r\n";
            retsult += "    }\r\n";
            retsult += "    .alert-warning .close{\r\n";
            retsult += "	    position:absolute;\r\n";
            retsult += "	    top:25px;\r\n";
            retsult += "	    right:25px;\r\n";
            retsult += "    }\r\n";
            retsult += "    .listbox{margin:10px 0 0 15px;}\r\n";
            retsult += "    .default-bg{\r\n";
            retsult += "        background-image: url(/public/home_v2/images/bg.jpg);\r\n";
            retsult += "        background-position: center center;	\r\n";
            retsult += "        background-repeat: no-repeat;\r\n";
            retsult += "        background-attachment: fixed;\r\n";
            retsult += "        background-size: cover;	\r\n";
            retsult += "        background-color: #464646;\r\n";
            retsult += "        position:absolute;width:100%;top:0;bottom:0;\r\n";
            retsult += "   }\r\n";
            retsult += "    .default-bg .header{height:90px;padding-top:20px;}\r\n";
            retsult += "    .default-bg .header .logo{width:206px;height:70px;display:inline-block}\r\n";
            retsult += "    .default-bg .header .login-info{height:70px;display:inline-block;text-align:right;float:right;line-height:70px;color:#fff;font-size:20px;}\r\n";
            retsult += "    .default-bg .header .login-info a {color:#FFFFFF;margin-left:20px;}\r\n";
            retsult += "    .default-bg .footer{position:absolute;bottom:0;left:0;text-align:center;color:#464646;padding:15px 0;width:100%;}\r\n";
            retsult += "    .default-bg .search{\r\n";
            retsult += "        display:block;margin:0 auto;background-color: rgba(255,255,255,0.3);margin:0 10%;min-height:400px;position:relative;padding-bottom:64px;\r\n";
            retsult += "    }\r\n";
            retsult += "-->\r\n";
            retsult += "</style>\r\n";
            retsult += "    <script src=\"/Public/Home/js/jquery1.7.2.js\" type=\"text/javascript\"></script>\r\n";
            retsult += "    <script src=\"/Public/Home/lhgdialog/lhgdialog.js?skin=discuz\" type=\"text/javascript\"></script>\r\n";
            retsult += "    <!--[if lt IE 9]>\r\n";
            retsult += "    <script>\r\n";
            retsult += "       document.createElement('figure');\r\n";
            retsult += "    </script>\r\n";
            retsult += "    <![endif]-->\r\n";
            retsult += "</head>\r\n";
            // retsult = retsult + "<body class=\"default-bg\">\r\n";
            retsult += "<body>\r\n";
            retsult += "<div class=\"Member_head\">\r\n";
            retsult += "    <a href=\"/\" class=\"logo_m\" style=\"margin:6px 0 0 20px;\"><img src=\"/Public/Home_v2/images/logo.png\"></a>\r\n";
            retsult += "            <div style=\"float: left;margin-top: 25px;margin-left: 100px;color: #fff;font-size: 20px;\"> </div>\r\n";
            retsult += "        <ul class=\"tui fr\">\r\n";
            retsult += "        <li class=\"tuiName fl\">\r\n";
            retsult += "            <span></span>\r\n";
            retsult += "            <em></em>\r\n";
            retsult += "        </li>\r\n";
            retsult += "        <li class=\"fl\" style=\"line-height:52px;margin-left:20px;\">\r\n";
            retsult += "                <a href=\"/\" target=\"_blank\" style=\"color:#fff;\">[返回查询首页]</a>\r\n";
            retsult += "                <a href=\"/member/Default.aspx\" style=\"color:#fff;\">[返回管理首页]</a>\r\n";
            retsult += "                <a href=\"/member/multi.aspx\" style=\"color:#fff;\">[上传报告]</a>\r\n";
            retsult += "                <a href=\"/member/report.aspx\" style=\"color:#fff;\">[报告管理]</a>\r\n";
            retsult += "                <a href=\"/member/instructions.aspx\"  style=\"color:#fff;\">[上传批件]</a>\r\n";
            retsult += "                <a href=\"/member/cert.aspx\" style=\"color:#fff;\">[批件管理]</a>\r\n";
            retsult += "                <a href=\"/member/drug.aspx\"  style=\"color:#fff;\">[商品管理]</a>\r\n";
            retsult += "                <a href=\"/member/customer.aspx\"  style=\"color:#fff;\">[单位管理]</a>\r\n";
            retsult += "                <a href=\"/member/invoice.aspx\"  style=\"color:#fff;\">[发票管理]</a>\r\n";
            retsult += "            <!--<a href=\"/member/invoicequery.aspx\"  style=\"color:#fff;\">[电子发票管理]</a>-->\r\n";
            retsult += "                <a href=\"/member/member.aspx\" style=\"color:#fff;\">[用户管理]</a>\r\n";
            retsult += "                <a href=\"/member/ConvertFileToSQL.aspx\" style=\"color:#fff;\">[共享报告导入]</a>\r\n";
            retsult += "                <a href=\"/member/ChangeActive.aspx\" style=\"color:#fff;\">[删除资料]</a>\r\n";
            retsult += "                <a href=\"/Login.aspx?login=logout\"  style=\"color:#fff;\">[退出]</a>\r\n";
            retsult += "        </li>\r\n";
            retsult += "    </ul>\r\n";
            retsult += "</div>\r\n";            
        }catch
        {
            HttpContext.Current.Response.Redirect("/Login.aspx");
        }
        return retsult;
    }

    public string InitIndex(string EnterpriseName, string UserPower)
    {
        LicenseState();
        string retsult = "";
        try
        {
            retsult += "<!DOCTYPE html>\r\n";
            retsult += "<html>\r\n";
            retsult += "<head>\r\n";
            retsult += "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n";
            retsult += "    <title>电子文档管理平台 - Powered by " + EntName + "</title>\r\n";
            retsult += "    <link href=\"/Public/Home/css/Member.css\" rel=\"stylesheet\" type=\"text/css\">\r\n";
            retsult += "<style type=\"text/css\">\r\n";
            retsult += "<!--\r\n";
            retsult += "    .QiyeC a{border:1px solid #d2ccc4;color:#666;padding: 3px 10px;display:inline-block;margin:5px 0;}\r\n";
            retsult += "    #delImage{display: block; position: absolute;bottom:5px;right:5px;background:#e95515;border:none;color:#FFF;overflow:visible;padding:5px 10px;cursor:pointer;}\r\n";
            retsult += "    .alert-warning{\r\n";
            retsult += "	    position:relative;\r\n";
            retsult += "	    margin:0 30px 15px;\r\n";
            retsult += "	    padding:25px;\r\n";
            retsult += "	    color:#a94442;\r\n";
            retsult += "	    background-color:#f2dede;\r\n";
            retsult += "	    border:1px solid #ebccd1;\r\n";
            retsult += "	    border-radius:4px;\r\n";
            retsult += "    }\r\n";
            retsult += "    .alert-warning .close{\r\n";
            retsult += "	    position:absolute;\r\n";
            retsult += "	    top:25px;\r\n";
            retsult += "	    right:25px;\r\n";
            retsult += "    }\r\n";
            retsult += "    .listbox{margin:10px 0 0 15px;}\r\n";
            retsult += "    .default-bg{\r\n";
            retsult += "        background-image: url(/public/home_v2/images/bg.jpg);\r\n";
            retsult += "        background-position: center center;	\r\n";
            retsult += "        background-repeat: no-repeat;\r\n";
            retsult += "        background-attachment: fixed;\r\n";
            retsult += "        background-size: cover;	\r\n";
            retsult += "        background-color: #464646;\r\n";
            retsult += "        position:absolute;width:100%;top:0;bottom:0;\r\n";
            retsult += "   }\r\n";
            retsult += "    .default-bg .header{height:90px;padding-top:20px;}\r\n";
            retsult += "    .default-bg .header .logo{width:206px;height:70px;display:inline-block}\r\n";
            retsult += "    .default-bg .header .login-info{height:70px;display:inline-block;text-align:right;float:right;line-height:70px;color:#fff;font-size:20px;}\r\n";
            retsult += "    .default-bg .header .login-info a {color:#FFFFFF;margin-left:20px;}\r\n";
            retsult += "    .default-bg .footer{position:absolute;bottom:0;left:0;text-align:center;color:#464646;padding:15px 0;width:100%;}\r\n";
            retsult += "    .default-bg .search{\r\n";
            retsult += "        display:block;margin:0 auto;background-color: rgba(255,255,255,0.3);margin:0 10%;min-height:400px;position:relative;padding-bottom:64px;\r\n";
            retsult += "    }\r\n";
            retsult += "-->\r\n";
            retsult += "</style>\r\n";
            retsult += "    <script src=\"/Public/Home/js/jquery1.7.2.js\" type=\"text/javascript\"></script>\r\n";
            retsult += "    <script src=\"/Public/Home/lhgdialog/lhgdialog.js?skin=discuz\" type=\"text/javascript\"></script>\r\n";
            retsult += "    <!--[if lt IE 9]>\r\n";
            retsult += "    <script>\r\n";
            retsult += "       document.createElement('figure');\r\n";
            retsult += "    </script>\r\n";
            retsult += "    <![endif]-->\r\n";
            retsult += "<script type=\"text/javascript\">\r\n";
            retsult += "/* 鼠标特效 */\r\n";
            retsult += "var a_idx = 0;\r\n";
            retsult += "jQuery(document).ready(function($) {\r\n";
            retsult += "    $(\"body\").click(function(e) {\r\n";
            retsult += "        var a = new Array(\"富强\", \"民主\", \"文明\", \"和谐\", \"自由\", \"平等\", \"公正\" ,\"法治\", \"爱国\", \"敬业\", \"诚信\", \"友善\");\r\n";
            retsult += "        var $i = $(\"<span />\").text(a[a_idx]);\r\n";
            retsult += "        a_idx = (a_idx + 1) % a.length;\r\n";
            retsult += "        var x = e.pageX,\r\n";
            retsult += "        y = e.pageY;\r\n";
            retsult += "        $i.css({\r\n";
            retsult += "            \"z-index\": 999999999999999999999999999999999999999999999999999999999999999999999,\r\n";
            retsult += "            \"top\": y - 20,\r\n";
            retsult += "            \"left\": x,\r\n";
            retsult += "            \"position\": \"absolute\",\r\n";
            retsult += "            \"font-weight\": \"bold\",\r\n";
            retsult += "            \"color\": \"#fa2a2a\"\r\n";
            retsult += "        });\r\n";
            retsult += "        $(\"body\").append($i);\r\n";
            retsult += "        $i.animate({\r\n";
            retsult += "            \"top\": y - 180,\r\n";
            retsult += "            \"opacity\": 0\r\n";
            retsult += "        },\r\n";
            retsult += "        1500,\r\n";
            retsult += "        function() {\r\n";
            retsult += "            $i.remove();\r\n";
            retsult += "        });\r\n";
            retsult += "    });\r\n";
            retsult += "});\r\n";
            retsult += "</script>\r\n";
            retsult += "</head>\r\n";
            retsult += "<body class=\"default-bg\">\r\n";
            //retsult += "<body>\r\n";
            retsult += "<div class=\"Member_head\">\r\n";
            retsult += "    <a href=\"/\" class=\"logo_m\" style=\"margin:6px 0 0 20px;\"><img src=\"/Public/Home_v2/images/logo.png\"></a>\r\n";
            retsult += "            <div style=\"float: left;margin-top: 25px;margin-left: 100px;color: #fff;font-size: 20px;\"> </div>\r\n";
            retsult += "        <ul class=\"tui fr\">\r\n";
            retsult += "        <li class=\"tuiName fl\">\r\n";
            // retsult += "            <span>欢迎 " + EnterpriseName + "</span>\r\n";
            retsult += "            <em></em>\r\n";
            retsult += "        </li>\r\n";
            retsult += "        <li class=\"fl\" style=\"line-height:52px;margin-left:20px;\">\r\n";
            retsult += "                <a href=\"/Default.aspx\" style=\"color:#fff;\">[返回首页]</a>\r\n";
            //retsult += "                <a href=\"/search/sale.aspx\" style=\"color:#fff;\">[出库单查询]</a>\r\n";
            retsult += "                <a href=\"/search/report.aspx\" style=\"color:#fff;\">[验报告查询]</a>\r\n";
            retsult += "                <a href=\"/search/cert.aspx\"  style=\"color:#fff;\">[商品信息查询]</a>\r\n";
            retsult += "                <a href=\"/search/invoice.aspx\"  style=\"color:#fff;\">[厂家发票查询]</a>\r\n";
            retsult += "                <a href=\"/search/electronic.aspx\"  style=\"color:#fff;\">[电子发票查询]</a>\r\n";
            /*
            retsult += "                <a href=\"/search/mydata.aspx\"  style=\"color:#fff;\">[我的资质]</a>\r\n";
            retsult += "                <a href=\"/Repass.aspx\"  style=\"color:#fff;\">[密码修改]</a>\r\n";
            if (UserPower.Contains("Manager"))
            {
                retsult += "                <a href=\"/Member/\" style=\"color:#ff0;\">[系统管理]</a>\r\n";
            }
            retsult += "                <a href=\"/Login.aspx?login=logout\"  style=\"color:#fff;\">[退出]</a>\r\n";
             */
            retsult += "        </li>\r\n";
            retsult += "    </ul>\r\n";
            retsult += "</div>\r\n";

        }
        catch
        {
            HttpContext.Current.Response.Redirect("/Login.aspx");
        }
        return retsult;
    }
    #endregion


    #region 初始化网页尾
    public string IndexFooter()
    {
        string retsult = "";
        retsult = "<div style=\"position: absolute;bottom: 0;left: 40%; text-align:center; font-size:6px; font-weight:bold; line-height:50px; margin-bottom:15px; color:#0C4A35;\">电子文档管理平台  &copy; 2019 " + EntName + "</div>";
        return retsult;
    }
    #endregion

    #region 是否登录验证
    /// <summary>
    /// 是否登录检查
    /// </summary>
    /// <returns></returns>
    public bool islogin()
    {
        bool result = false;
        try
        {
            if (!string.IsNullOrEmpty(HttpContext.Current.Session["UserID"].ToString()) && !string.IsNullOrEmpty(HttpContext.Current.Session["Pass"].ToString()) && !string.IsNullOrEmpty(HttpContext.Current.Session["EnterpriseName"].ToString()))
            {
                result = true;
            }
        }
        catch
        {
            result = false;
        }
        result = true;
        return result;
    }
    public bool islogin(ref string UserID, ref string EnterpriseName, ref string UserPower)
    {
        bool result = false;
        try
        {
            if (!string.IsNullOrEmpty(HttpContext.Current.Session["UserID"].ToString()) && !string.IsNullOrEmpty(HttpContext.Current.Session["Pass"].ToString()) && !string.IsNullOrEmpty(HttpContext.Current.Session["EnterpriseName"].ToString()))
            {
                UserID = HttpContext.Current.Session["UserID"].ToString();
                EnterpriseName = HttpContext.Current.Session["EnterpriseName"].ToString();
                UserPower = HttpContext.Current.Session["UserPower"].ToString();
                result = true;
            }
        }
        catch
        {
            result = false;
        }
        UserPower = "Manager,invoice,sale,cert,electronic,report,member";
        result = true;
        return result;
    }
    /// <summary>
    /// 退出登录
    /// </summary>
    /// <returns></returns>
    public bool logout()
    {
        if (!string.IsNullOrEmpty(HttpContext.Current.Session["UserID"].ToString()))
        {
            HttpContext.Current.Session["UserID"] = "";
            HttpContext.Current.Session["Pass"] = "";
            HttpContext.Current.Session["EnterpriseName"] = "";
            HttpContext.Current.Session["UserPower"] = "";
        }
        return true;
    }
    #endregion

    #region 生成页码的html
    /// <summary>
    /// 生成页码的html
    /// </summary>
    /// <param name="urlFormat">超链接的格式。list.ashx?pagenum={pageNum}。地址中用{pagenum}做为当前页码的占位符</param></param>
    /// <param name="totalSize">总数据条数</param>
    /// <param name="pageSize">每页多少条数据</param>
    /// <param name="currentPage">当前页</param>
    /// <returns></returns>
    public String Pager(string urlFormat, long totalSize, long pageSize, long currentPage = 1)
    {
        StringBuilder sb = new StringBuilder();
        //总页数
        long totalPageCount = (long)Math.Ceiling((totalSize * 1.0f) / (pageSize * 1.0f));
        //当前页的前几页
        long firstPage = Math.Max(currentPage - 5, 1);
        //当前页的后几页
        long lastPage = Math.Min(currentPage + 6, totalPageCount);
        //绘制分页,首页
        sb.AppendLine("<div class=\"bot\"><ul class=\"fr s2\"><li class=\"pageList\">");
        if (currentPage > 1)
        {
            sb.AppendLine("<a href='" + urlFormat.Replace("{pageNum}", "1") + "'>首页</a>");
        }
        //绘制分页中间数据部分
        for (long i = firstPage; i <= lastPage; i++)
        {
            string url = urlFormat.Replace("{pageNum}", i.ToString());
            if (i == currentPage) //点击后就不显示超链接
            {
                sb.AppendLine("<a href=\"javascript:;\" class=\"pagelistH\">" + i + "</a>");
            }
            else
            {
                sb.AppendLine("<a href='" + url + "'>" + i + "</a>");
            }
        }
        //显示最后一页        
        //sb.AppendLine("<form method=\"get\" action=\"/Default.aspx\" style=\"float:left;\"><input type=\"text\" name=\"p\" style=\"float:left;width:40px;height:30px;line-height:30px;border:1px solid #e5e5e5;text-align:center;margin:0 -1px 0 3px;\" value=\"" + currentPage.ToString() + "\" /><input type=\"submit\" style=\"height:32px;line-height:32px;float:left;width:40px;\" value=\"跳转\" /></form>");
        sb.AppendLine("<a href='" + urlFormat.Replace("{pageNum}", totalPageCount.ToString()) + "'>末页</a>");
        if (currentPage + 1 <= totalPageCount)
        {
            sb.AppendLine("<a href='" + urlFormat.Replace("{pageNum}", (currentPage + 1).ToString()) + "'>下一页</a>");
        }
        sb.AppendLine(" <a href=\"javascript:;\">共 " + totalSize + " 条记录，第 " + currentPage + "/" + totalPageCount + " 页</a>");
        sb.AppendLine("</li></ul></div>");
        return sb.ToString();
    }
    #endregion

    #region  单据编号检索
    /// <summary>
    /// 生成最大编号
    /// </summary>
    /// <returns></returns>
    public string ndjbh()
    {
        string r = "00000000";
        string ndjbh = "TUP00000000";
        int maxbh = 0;
        Init();
        maxbh = int.Parse(djbh.Substring(3, 8)) + 1;
        r = "00000000" + maxbh.ToString();
        ndjbh = "TUP" + r.Substring(maxbh.ToString().Length, 8);
        return ndjbh;
    }
    /// <summary>
    /// 获取最大编号
    /// </summary>
    /// <returns></returns>
    public string maxbh()
    {

        string sql = "select recnum from [maxbh](nolock) where biaoshi='IMT'";
        SqlDataReader dr1 = mssql.ExecuteReader(sql);
        if (dr1.Read())
        {
           int recnum = int.Parse(dr1["recnum"].ToString())+1;
           string r = "00000000" + recnum.ToString();
           string nmaxbh = "IMT" + r.Substring(recnum.ToString().Length, 8);
           mssql.ExecuteSql("update [maxbh] set recnum=recnum+1 where biaoshi='IMT'");
           return nmaxbh;           
        }
        else
        {
            mssql.ExecuteSql("insert into [maxbh](biaoshi,recnum,mkbh)values('IMT',0,'YN')");
            return "IMT00000000";
        }       
    }
    /// <summary>
    /// 获取最大编号
    /// </summary>
    /// <param name="IDHead">编号头</param>
    /// <returns></returns>
    public string maxbh(string IDHead)
    {

        string sql = "select recnum from [maxbh](nolock) where mkbh='YN' and biaoshi='" + IDHead + "'";
        SqlDataReader dr1 = mssql.ExecuteReader(sql);
        if (dr1.Read())
        {
            int recnum = int.Parse(dr1["recnum"].ToString()) + 1;
            string r = "00000000" + recnum.ToString();
            string nmaxbh = "SCA" + r.Substring(recnum.ToString().Length, 8);
            mssql.ExecuteSql("update [maxbh] set recnum=recnum+1 where mkbh='YN' and biaoshi='" + IDHead + "'");
            return nmaxbh;
        }
        else
        {
            mssql.ExecuteSql("insert into [maxbh](biaoshi,recnum,mkbh)values('" + IDHead + "',0,'YN')");
            return IDHead+"00000000";
        }
    }
    #endregion

    public string GetInterIDList(string strfile)
    {
        string strout;
        strout = "";
        if (!File.Exists(HttpContext.Current.Server.MapPath(strfile)))
        {
        }
        else
        {
            StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath(strfile), Encoding.Default);
            String input = sr.ReadToEnd();
            sr.Close();
            strout = input;
        }
        return strout;
    }

    #region 该方法用于生成指定位数的随机字符串
    /// <summary>
    /// 该方法用于生成指定位数的随机字符串
    /// </summary>
    /// <param name="VcodeNum">参数是随机数的位数</param>
    /// <returns>返回一个随机数字符串</returns>
    public static string RndNumStr(int VcodeNum)
    {
        string[] source = { "0", "1", "1", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };

        string checkCode = String.Empty;
        Random random = new Random();
        for (int i = 0; i < VcodeNum; i++)
        {
            checkCode += source[random.Next(0, source.Length)];
        }
        return checkCode;
    }
    #endregion

    #region JSON

    //Context.Response.Write("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"list\":[{\"name\":\"张三\",\"value\":\"0\"},{\"name\":\"张三A\",\"value\":\"0\"},{\"name\":\"张三B\",\"value\":\"0\"},{\"name\":\"张三C\",\"value\":\"0\"}]}}");
    public string dsToJsonList(DataSet ds, string Type)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"result\":0,\"userList\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        //str.Append("{\"length\":\"" + ds.Tables[0].Rows.Count + "\"}");

        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }

        str.Append("]}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }
    public string dsToJsonList(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"result\":0,\"userList\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        //str.Append("{\"length\":\"" + ds.Tables[0].Rows.Count + "\"}");

        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }

        str.Append("]}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }
    public string dsToJsonData(DataSet ds, string Type)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("\"" + Type + "\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        //str.Append("{\"length\":\"" + ds.Tables[0].Rows.Count + "\"}");

        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }

        str.Append("]");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJson(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        str.Append("]}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonDetaillist(DataSet dsDetail, string TypeDetail, DataSet dslist, string Typelist)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"" + TypeDetail + "\":[");
        for (int i = 0; i < dsDetail.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < dsDetail.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", dsDetail.Tables[0].Columns[j].ColumnName, dsDetail.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (dsDetail.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        str.Append("],\"" + Typelist + "\":[");
        /****/
        for (int i = 0; i < dslist.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < dslist.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", dslist.Tables[0].Columns[j].ColumnName, dslist.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (dslist.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        str.Append("]");
        str.Append("}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsons(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功B\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"model\":{\"length\":\"" + ds.Tables[0].Rows.Count + "\",");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("\"" + i + "\":{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("}}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonTop(DataSet ds, string TypeDetail)
    {
        //Context.Response.Write("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"visitCount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}],\"orderCount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}],\"tradeAmount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}],\"inquiryCount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}],\"visitCount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}],\"orderCount\":[{\"name\":\"1\"},{\"name\":\"2\"},{\"name\":\"3\"}]}}");
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        //str.Append("{\"success\":true,\"msg\":\"成功B\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"model\":{");
        str.Append("\"" + TypeDetail + "\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (ds.Tables[0].Rows.Count > 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        str.Append("]");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonDetail(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"display\":\"block\",\"model\":");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (ds.Tables[0].Rows.Count > 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        else
        {
            str.Append("\"\"");
        }
        str.Append("}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonDetail(DataSet ds, string TypeDetail)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"" + TypeDetail + "\":");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonDetailGroupx(DataSet ds1, DataSet ds2)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功C\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"members\":[");
        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds1.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds1.Tables[0].Columns[j].ColumnName, ds1.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("],");

        for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
        {
            //str.Append("{");
            for (int j = 0; j < ds2.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds2.Tables[0].Columns[j].ColumnName, ds2.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            //str.Append("},");
            str.Append(",");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonDetailGroup(DataSet ds1, DataSet ds2)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功C\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"list\":[");
        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds1.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds1.Tables[0].Columns[j].ColumnName, ds1.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("],");

        for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
        {
            //str.Append("{");
            for (int j = 0; j < ds2.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds2.Tables[0].Columns[j].ColumnName, ds2.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            //str.Append("},");
            str.Append(",");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJson_bak(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("[");
        for (int o = 0; o < ds.Tables.Count; o++)
        {
            str.Append("{");
            str.Append(string.Format("\"{0}\":[", ds.Tables[o].TableName));

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                str.Append("{");
                for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                {
                    str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
                }
                str.Remove(str.Length - 1, 1);
                str.Append("},");
            }
            str.Remove(str.Length - 1, 1);
            str.Append("]},");
        }
        str.Remove(str.Length - 1, 1);
        str.Append("]");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonReferralLog(DataSet ds, int todaySuccessReferralNum, int thisMonthSuccessReferralNum)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功D\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":{\"referralLogDTOs\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        //str.Append(",{\"length\":\"" + ds.Tables[0].Columns.Count + "\"}");

        str.Append("],\"todaySuccessReferralNum\":" + todaySuccessReferralNum + ",\"thisMonthSuccessReferralNum\":" + thisMonthSuccessReferralNum + "}}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonfor(DataSet ds)
    {
        int num = 3;
        System.Text.StringBuilder str = new System.Text.StringBuilder("");
        str.Append("{\"success\":true,\"msg\":\"成功\",\"errorMsg\":\"成功\",\"errorCode\":\"0\",\"model\":[");
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                if (j % num == 0 && j != 0)
                {
                    str.Append("\"children\":[{");
                }
                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);

            for (int b = 0; b < num; b++)
            {
                str.Append("}]");
            }
            str.Remove(str.Length - 1, 1);
            str.Append(",");
        }

        if (ds.Tables[0].Rows.Count != 0)
        {
            str.Remove(str.Length - 1, 1);
        }
        str.Append("]}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }

    public string dsToJsonTfor(DataSet ds)
    {
        System.Text.StringBuilder str = new System.Text.StringBuilder("");

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            str.Append("{");
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {

                str.Append(string.Format("\"{0}\":\"{1}\",", ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[i][j].ToString()));
            }
            str.Remove(str.Length - 1, 1);
            str.Append("},");
        }
        str.Append("]}");
        str = str.Replace("\r\n", "\\r\\n").Replace("\r", "\\r").Replace("\n", "\\n");
        return str.ToString();
    }
    #endregion

    #region 日志
    /// <summary>
    /// 生成日志文件
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="isdebug"></param>
    public void WriteLog(string msg, bool isdebug)
    {
        string text = AppDomain.CurrentDomain.BaseDirectory;
        text = Path.Combine(text, "log");
        if (!Directory.Exists(text))
        {
            Directory.CreateDirectory(text);
        }
        if (isdebug)
        {
            text = Path.Combine(text, "debug");
            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
        }
        text = Path.Combine(text, DateTime.Now.ToString("yyyyMMdd") + ".txt");
        if (!File.Exists(text))
        {
            File.CreateText(text).Close();
        }
        StreamWriter streamWriter = new StreamWriter(text, true, Encoding.UTF8);
        if (isdebug)
        {
            streamWriter.WriteLine("--------------------------------------------------------------------------------------------------------------------------------");
        }
        streamWriter.WriteLine("{0}  {1}", DateTime.Now.ToString("yyyyMMdd HH:mm:ss"), msg);
        if (isdebug)
        {
            streamWriter.WriteLine("--------------------------------------------------------------------------------------------------------------------------------");
        }
        streamWriter.Flush();
        streamWriter.Close();
    }
    /// <summary>
    /// 清理日志文件
    /// </summary>
    public void ClearLog()
    {
        string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log");
        if (Directory.Exists(path))
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            FileInfo[] files = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories);
            FileInfo[] array = files;
            for (int i = 0; i < array.Length; i++)
            {
                FileInfo fileInfo = array[i];
                if (DateTime.Now.Subtract(fileInfo.CreationTime).Days > 30)
                {
                    File.Delete(fileInfo.FullName);
                }
            }
        }
    }
    #endregion


    /// <summary>
    /// 授权状态
    /// </summary>
    public void LicenseState()
    {
         if (DateTime.Now > Convert.ToDateTime("2021-12-31"))
          {
             HttpContext.Current.Response.Write("加载LoadResourceDll时出错\n找不到指定的模块。");
             HttpContext.Current.Response.End();         
          }                    
    }

    /// <summary>
    /// 字符转ASCII
    /// </summary>
    /// <param name="xmlStr"></param>
    /// <returns></returns>
    public int str2ASCII(string xmlStr)
    {
        byte[] bytes = Encoding.ASCII.GetBytes(xmlStr);
        return (int)bytes[0];
    }

    #region 加密解密
    /// <summary>
    /// 解密
    /// </summary>
    /// <param name="txtStr"></param>
    /// <returns></returns>
    public string Decrypt(string txtStr)
    {
        string[] keyA = new string[6];
        string[] keyB = new string[6];
        keyA[0] = "wa6j1c";
        keyA[1] = "fblrk7";
        keyA[2] = "mg9q0s";
        keyA[3] = "vu3zth";
        keyA[4] = "po4xy2";
        keyA[5] = "ni5d8e";

        keyB[0] = "ke3wms";
        keyB[1] = "jnx9i8";
        keyB[2] = "dpqzl6";
        keyB[3] = "vyg1bh";
        keyB[4] = "7a4c2f";
        keyB[5] = "u5rto0";
        try
        {
            string text2 = A(txtStr.ToLower(), keyA);
            int i = 0;
            for (int k = 0; k <= 2; k++)
            {
                i = i * 6 + int.Parse(text2.Substring(k, 1));
            }
            text2 = text2.Substring(3, i);
            string result = jdMethod_if(text2, keyB);
            return result;
        }
        catch (Exception e)
        {
            string result = "Error：" + e.Message;
            return result;
        }
    }
    /// <summary>
    /// 加密
    /// </summary>
    /// <param name="txtStr"></param>
    /// <returns></returns>
    public string Encrypt(string txtStr)
    {
        string[] keyA = new string[6];
        string[] keyB = new string[6];
        keyA[0] = "wa6j1c";
        keyA[1] = "fblrk7";
        keyA[2] = "mg9q0s";
        keyA[3] = "vu3zth";
        keyA[4] = "po4xy2";
        keyA[5] = "ni5d8e";

        keyB[0] = "ke3wms";
        keyB[1] = "jnx9i8";
        keyB[2] = "dpqzl6";
        keyB[3] = "vyg1bh";
        keyB[4] = "7a4c2f";
        keyB[5] = "u5rto0";
        try
        {
            string text2 = A(txtStr.ToLower(), keyB);
            int i = text2.Length;
            for (int k = 0; k <= 2; k++)
            {
                text2 = (i % 6).ToString() + text2;
                i = i / 6;
            }
            string result = "";
            Random r = new Random();
            for (int n = 0; text2.Length < 60; n++)
            {
                text2 = text2 + r.Next(6).ToString();
                result = jdMethod_if(text2, keyA);
            }
            return result;
        }
        catch (Exception e)
        {
            string result = "Error：" + e.Message;
            return result;
        }
    }

    public string A(string txtStr, string[] keyA)
    {
        string str = "";
        string str2 = "";

        for (int i = 0; i < txtStr.Length; i++)
        {
            for (int j = 0; j < 6; j++)
            {
                int k = keyA[j].IndexOf(txtStr.Substring(i, 1)) + 1;
                if (k > 0)
                {
                    str += j.ToString();
                    str2 = (k - 1).ToString() + str2;
                    break;
                }
            }
        }
        string text2 = str + str2;
        return text2;
    }
    public string jdMethod_if(string txtStr, string[] keyB)
    {
        string result = "";
        if (txtStr.Length % 2 == 1)
        {
            result = "";
        }
        else
        {
            for (int k = 0; k < txtStr.Length / 2; k++)
            {
                result += keyB[str2ASCII(txtStr.Substring(k, 1)) - str2ASCII("0")].Substring(str2ASCII(txtStr.Substring(txtStr.Length - k - 1, 1)) - str2ASCII("0"), 1);
            }
        }
        return result;
    }
    #endregion

    #region SQL过滤不安全字符
    /// <summary>
    /// 过滤不安全的字符串
    /// </summary>
    /// <param name="Str"></param>
    /// <returns></returns>
    public string FilteSQLStr(string Str)
    {
        Str = Str.ToLower();
        Str = Str.Replace("'", "");
        Str = Str.Replace("\"", "");
        Str = Str.Replace("&", "&amp");
        Str = Str.Replace("<", "&lt");
        Str = Str.Replace(">", "&gt");
        Str = Str.Replace(";", "");

        Str = Str.Replace("delete", "");
        Str = Str.Replace("update", "");
        Str = Str.Replace("insert", "");
        Str = Str.Replace("drop", "");
        Str = Str.Replace("exec", "");
        Str = Str.Replace("join", "");
        Str = Str.Replace("declare", "");
        Str = Str.Replace("drop", "");
        return Str;
    }
    #endregion

    #region 判断文件是否存在
    public bool isFile(string PathFile)
    {
        bool flag = false;
        flag = File.Exists(@PathFile) ? true : false;
        return flag;
    }
    #endregion


    #region 多个硬盘存放图片自动检测调用图片位置
    public string imagefileurl(string pathfile)
    {

        if (isFile("G:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Upload1");
        }
        if (isFile("H:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Upload");
        }
        if (isFile("I:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Upload2");
        }
        if (isFile("I:\\Share\\" + pathfile.Replace("/Share", "\\")))
        {
            return "/Share2/"+pathfile.Replace("/Share", "/");
        }
        if (isFile("H:\\Share\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Share");
        }
        if (isFile("H:\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Share");
        }

        if (isFile("F:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Upload");
        }
        if (isFile("F:\\Share\\" + pathfile.Replace("/Upload", "\\")))
        {
            return pathfile.Replace("/Upload", "/Share");
        }
        return "";
    }

    public string imagefilepath(string pathfile)
    {
        if (isFile("H:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "H:\\tupian\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("G:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "G:\\tupian\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("I:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "I:\\tupian\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("I:\\Share\\" + pathfile.Replace("/Share", "\\")))
        {
            return "I:\\Share\\" + pathfile.Replace("/Share", "\\");
        }
        if (isFile("H:\\Share\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "H:\\Share\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("H:\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "H:\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("F:\\tupian\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "F:\\tupian\\" + pathfile.Replace("/Upload", "\\");
        }
        if (isFile("F:\\Share\\" + pathfile.Replace("/Upload", "\\")))
        {
            return "F:\\Share\\" + pathfile.Replace("/Upload", "\\");
        }
        return "";
    }
    #endregion
}